package com.gitee.wsgalaxy.gnodroid;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;

import com.gitee.wsgalaxy.gnodroid.connect.GndConnect;

/**
 * Created by wsgalaxy on 3/15/18.
 */

public class GndMainService extends Service {

    MyBinder binder = new MyBinder();
    GndConnect connect = null;

    @Override
    public void onCreate()
    {
        Log.d("gnd", "service create");
        GndGlobal.registeAllModule();                       //注册所有的模块
        GndGlobal.setContext(this);
        connect = GndConnect.getConnect(GndGlobal.PORT);    //创建网络监听
        connect.start();        //启动网络监听
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        Log.d("gnd", "command start");
        return super.onStartCommand(intent, flags, startId);
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        Log.d("gnd", "onbind");
        return binder;
    }

    public class MyBinder extends Binder {
        public GndMainActivity activity = null;
        public void status()
        {
            Log.d("gnd", "status");

        }
    }

}
